<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <label for="">
        账号<input type="text" class="text">
    </label>
    <br><br>
    <label for="">
        密码<input type="password" class="pwd">
    </label>
    <br><br>
    <label for="">
        记住密码<input type="checkbox" class="check">
    </label>
    <br><br>
    <button>登录</button>

    <script>
        var textBtton = document.querySelector(".text");
        var pwdBtton = document.querySelector(".pwd");
        var checkBtton = document.querySelector(".check");

        document.querySelector("button").onclick = function () {
            if(pwdBtton.value === "" || textBtton.value === "") {
                alert("用户名或者密码为空，请填写完成");
                return
            }

            if(checkBtton.checked) {
                window.localStorage.setItem("userName",textBtton.value);
                window.localStorage.setItem("pwd",pwdBtton.value);

            }else {
                window.localStorage.removeItem("userName");
                window.localStorage.removeItem("pwd");
            }
        }

    </script>
</body>
</html>